import axios from 'axios'

axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';

export const getHttp = (url) => {
    return axios({
        method: 'get',
        url,
        headers: {
            'X-Custom-Header': 'foobar',
            'Authorization':localStorage.getItem('token') || '877a11d1-f7b8-426b-a5a8-8c92a89b8cb3'
        },
        timeout: 10000,
    }).then(data => {
        return data.data
    }).catch(err => {
        return err.message
    })
}


export const postHttp = (url, data) => {
    return axios({
        method: 'post',
        url,
        data,

    }).then(data => {
        return data.data
    }).catch(err => {
        return err.message
    })
}